#include <iostream>

using namespace std;

int Range = 20000;


bool IsPrime_V1(int x)
{
	for (int j = 2; j < x ; j++){
		if (x % j == 0) return false;
	}
	return true;
}

bool IsPrime_V2(int x)
{
	for (int j = 2; j * j <= x; j++){
		if (x % j == 0) return false;
	}
	return true;
}

int main()
{
	int Line = 0;
	for (int i = 1; i <= Range; i++){
		if (IsPrime_V2(i)){
			cout << i << " ";
			Line++;
			if (Line % 5 == 0) cout << endl;
		}
	}	
	return 0;
}
